package t3;

import java.io.FileOutputStream;
import java.io.IOException;
import java.util.List;

import t3bean.ChargeRecordBean;
import t3bean.ParkingLotBean;
import t3bean.ParkingSpaceBean;

public class Serialize {
	public void serialize(ParkingLotBean pl) throws IOException {
		FileOutputStream fos = new FileOutputStream("D:\\T1\\ParkingLot.txt");
		List<ParkingSpaceBean> spaceList = pl.getpSList();
		List<ChargeRecordBean> recordList = pl.getcRList();
		for (int i = 0; i < spaceList.size(); ++i) {
			fos.write(String.valueOf(spaceList.get(i).getId()).getBytes());
			fos.write("\n".getBytes());
			fos.write(String.valueOf(spaceList.get(i).getIsParking()).getBytes());
			fos.write("\n".getBytes());
			fos.write(String.valueOf(spaceList.get(i).getCar().getHeight()).getBytes());
			fos.write("\n".getBytes());
			fos.write(String.valueOf(spaceList.get(i).getCar().getLicensePlate()).getBytes());
			fos.write("\n".getBytes());
			fos.write(String.valueOf(spaceList.get(i).getParkingTime()).getBytes());
			fos.write("\n".getBytes());
		}
		fos.write("\n".getBytes());
		for (int i = 0; i < recordList.size(); ++i) {
			fos.write(String.valueOf(recordList.get(i).getCharge()).getBytes());
			fos.write("\n".getBytes());
			fos.write(recordList.get(i).getLicensePlate().getBytes());
			fos.write("\n".getBytes());
		}
		fos.close();

	}
}
